package com.shengruan.admin.jdbc;

import java.sql.Connection;
import java.sql.SQLException;

import com.shengruan.admin.vo.SystemEmail;
import com.shengruan.framework.jdbc.BaseJdbc;
import com.shengruan.framework.jdbc.BeanHandler;

public class SystemEmailJdbc extends BaseJdbc{

	/**
	 * 更新
	 */
	public void update(SystemEmail systemEmail)
	{
		Connection conn = this.getConnection();
		
		String sql = "update SystemEmail set " +
				"server=?,userName=?,password=? " +
				" where id=1";
		try {
			this.execute(conn, sql,systemEmail.getServer(),systemEmail.getUserName(),systemEmail.getPassword());
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			this.close(conn);
		}
	}
	
	/**
	 * 获得
	 */
	public SystemEmail getSystemEmail()
	{
		SystemEmail systemEmail = null;
		Connection conn = this.getConnection();
	
		String sql = "select * from SystemEmail where id=1";
		
		try {
			systemEmail = this.query(conn, sql, new BeanHandler<SystemEmail>(SystemEmail.class));
		
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			this.close(conn);
		}
		return systemEmail;
	}
	
}
